{% extends 'myadmin/index.html' %}

{% block title %}
<title>后台-下架商品列表</title>
{% endblock %}

{% block con %}
<div class="row-content am-cf">
    <div class="row">
        <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
            <div class="widget am-cf">
                <div class="widget-head am-cf">
                    <div class="widget-title  am-cf">下架商品列表</div>
                </div>
                <div class="widget-body  am-fr">

                    <div class="am-u-sm-12 am-u-md-6 am-u-lg-6">
                        <div class="am-form-group">
                            <div class="am-btn-toolbar">
                                <div class="am-btn-group am-btn-group-xs">
                                    <a href="{% url 'myadmin_goods_add' %}" class="am-btn am-btn-default am-btn-success"><span class="am-icon-plus"></span> 新增</a>
                                </div>
                            </div>
                        </div>
                    </div>

                <form >
                    <div class="am-u-sm-12 am-u-md-6 am-u-lg-3">
                        <div class="am-form-group tpl-table-list-select">
                            <select name="types" data-am-selected="{btnSize: 'sm'}" style="display: none;">
                              <option value="title" {% if request.GET.types == 'title' %} selected {% endif %}>商品标题</option>
                              <option value="price" {% if request.GET.types == 'price' %} selected {% endif %}>价格</option>
                              <option value="status" {% if request.GET.types == 'status' %} selected {% endif %}>状态</option>
                            </select>
                        </div>
                    </div>
                    <div class="am-u-sm-12 am-u-md-12 am-u-lg-3">
                        <div class="am-input-group am-input-group-sm tpl-form-border-form cl-p">
                            <input value="{{ request.GET.keywords }}" name="keywords" type="text" class="am-form-field ">
                            <span class="am-input-group-btn">
                                <button id="search" class="am-btn  am-btn-default am-btn-success tpl-table-list-field am-icon-search"></button>
                              </span>
                        </div>
                    </div>
                </form>

                    <div class="am-u-sm-12">
                        <table width="100%" class="am-table am-table-compact am-table-striped tpl-table-black ">
                            <thead>
                                <tr>
                                    <th>ID</th>
                                    <th>商品缩略图</th>
                                    <th>商品标题</th>
                                    <th>价格</th>
                                    <th>库存</th>
                                    <th>点击量</th>
                                    <th>购买量</th>
                                    <th>状态</th>
                                    <th>发布时间</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody>
                                {% for v in goodslist %}
                                <tr>
                                    <td>{{ v.id }}</td>
                                    <td>
                                        <img src="{{ v.pic_url }}" class="tpl-table-line-img" alt="">
                                    </td>
                                    <td class="am-text-middle">{{ v.title }}</td>
                                    <td class="am-text-middle">{{ v.price }}</td>
                                    <td class="am-text-middle">{{ v.store }}</td>
                                    <td class="am-text-middle">{{ v.clicknum }}</td>
                                    <td class="am-text-middle">{{ v.ordernum }}</td>
                                   
                                    <td class="am-text-middle">
                                        {% if v.status == 0 %}
                                            新品
                                        {% elif v.status == 1 %}
                                            热卖
                                        {% elif v.status == 2 %}
                                            下架
                                        {% endif %}
                                    </td>
                                    <td class="am-text-middle">{{ v.addtime }}</td>
                                    <td class="am-text-middle">
                                        <div class="tpl-table-black-operation">
                                            <a href="{% url 'myadmin_goods_open' v.id %}" class="tpl-table-black-operation">
                                                <i class="am-icon-pencil"></i> 还原
                                            </a>
                                            <a href="{% url 'myadmin_goods_delete' v.id %}" class="tpl-table-black-operation-del">
                                                <i class="am-icon-trash"></i> 删除
                                            </a>
                                        </div>
                                    </td>
                                </tr>
                                {% endfor %}
                      
                                <!-- more data -->
                            </tbody>
                        </table>
                    </div>
                    <div class="am-u-lg-12 am-cf">

                        <div class="am-fr">
                            <ul class="am-pagination tpl-pagination">
                                {% load pagetag %}

                                {% ShowPages goodslist.paginator.num_pages request %}
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script type="text/javascript">

    // 给搜索按钮绑定单击事件
    $('#search').click(function(){
        // 获取选框的值
        var v = $('select[name=types]').val()
        // 判断类型
        if(v == 'price'){
            // 获取输入的关键字,检测是否正确
            var k = $('input[name=keywords]').val()
            var reg = /^(\d+|\d+\.\d+),(\d+|\d+\.\d+)$/
            if(!reg.test(k)){
                alert('输入的格式不正确,格式为:100,200')
                return false;
            }
        }
    })
</script>
{% endblock %}